	<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <link rel="shortcut icon" href="<!--{eval echo register_static('img/touch-icon-57x57.png');}-->">

        <title>粉粉管理系统</title>

        <!-- Bootstrap core CSS -->
        <link href="<!--{eval echo register_static('css/bootstrap.min.css');}-->" rel="stylesheet">
        <link href="<!--{eval echo register_static('css/bootstrap-reset.css');}-->" rel="stylesheet">

        <!--Animation css-->
        <link href="<!--{eval echo register_static('css/animate.css');}-->" rel="stylesheet">

        <!--Icon-fonts css-->
        <link href="<!--{eval echo register_static('assets/font-awesome/css/font-awesome.css');}-->" rel="stylesheet" />
        <link href="<!--{eval echo register_static('assets/ionicon/css/ionicons.min.css');}-->" rel="stylesheet" />
        
        <link href="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.css');}-->" rel="stylesheet">
        
        <!-- Plugins css -->
        <link href="<!--{eval echo register_static('assets/modal-effect/css/component.css');}-->" rel="stylesheet">

        <!-- DataTables -->
        <link rel="stylesheet" href="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.css" rel="stylesheet');}-->" />

        <!-- Custom styles for this template -->
        <link href="<!--{eval echo register_static('css/style.css');}-->" rel="stylesheet">
        <link href="<!--{eval echo register_static('css/helper.css');}-->" rel="stylesheet">

        <!-- My styles for this template -->
        <link href="<!--{eval echo register_static('css/common.css');}-->" rel="stylesheet">
        
    </head>

    <body>

        <!-- Aside Start-->
        <!--{template admin_v2/leftside}-->
        <!-- Aside Ends-->


        <!--Main Content Start -->
        <section class="content">
            
            <!-- Header -->
            <!--{template admin_v2/header}-->
            <!-- Header Ends -->


            <!-- Page Content Start -->
            <!-- ================== -->

            <div class="wraper container-fluid diary-list">
            
            	<div class="row">
                    <div class="col-md-12">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">点滴列表</h3>
                            </div>
                            <div class="panel-body">
                            	<div class="row">
                            		<div class="col-md-2 col-sm-4 col-xs-4">
                                        <span class="btn btn-success getJoinNum" data-gid="{$gid}">获取</span>
                            			共<span class="label label-success diarynum">0</span>点滴，
                            			<span class="label label-success joinnum" >0</span>人参与
                            		</div>
                            		<div class="col-md-2 col-sm-4 col-xs-4">
                            			<a href="admin.php?ac=diarytopic_class&op=getDiarysByTopic&top=comment&gid={$gid}" class="btn btn-primary topsort">评论最多的点滴TOP50</a>
                            		</div>
                            		<div class="col-md-2 col-sm-4 col-xs-4">
                            			<a href="admin.php?ac=diarytopic_class&op=getDiarysByTopic&top=like&gid={$gid}" class="btn btn-primary topsort">喜欢最多的点滴TOP50</a>
                            		</div>
									<div class="col-md-2 col-sm-4 col-xs-4">
										<a href="admin.php?ac=diarytopic_class&op=getDiarysByTopic&display=1&gid={$gid}" class="btn btn-primary topsort">置顶的点滴</a>
									</div>
                                    <div class="col-md-2 col-sm-4 col-xs-4">
                                        <a href="admin.php?ac=diarytopic_class&op=getDiarysByTopic&hot=1&gid={$gid}" class="btn btn-primary topsort">热门点滴</a>
                                    </div>
                            	</div>
                            	<br/>
                                <div class="row">
                                    <div class="col-md-12 col-sm-12 col-xs-12">
                                        <table id="datatable" class="table table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th width="70%">点滴缩略语</th>
                                                    <th>话题</th>
				                                    <th>操作</th>
                                                </tr>
                                            </thead>

                                            <tbody>
                                            	<!--{loop $list $diary}-->
                                                <tr>
                                                    <td>
                                                    	<p><a href="admin.php?ac=diary_class&op=getDiaryDetail&bodyId=$diary['bodyId']&uid=$diary['detail']['user']['uid']">$diary['detail']['abbreviation']</a></p>
                                                    	<blockquote>
                                                            <div>
                                                                <!--{loop $diary['attachmentList'] $alist}-->
                                                                <!--{if $alist['attachmentType']==1}-->
                                                                <img src="http://img.fenfenriji.com<!--{$alist['attachmentPath']}-->" class="showImg" style="max-width: 100px; max-height: 100px" />
                                                                <!--{/if}-->
                                                                <!--{/loop}-->
                                                                <!--{loop $diary['detail']['videoList'] $alist}-->
                                                                <!--{if $alist['attachmentType']==3}-->
                                                                <video width="300" height="300" style="width: 300px;height: 300px;" controls="" name="media">
                                                                    <source src="http://media.fenfenriji.com<!--{$alist['attachmentPath']}-->" type="video/mp4">
                                                                </video>
                                                                <!--{/if}-->
                                                                <!--{/loop}-->
                                                            </div>
                                                    		<!--{if $diary['detail']['display']}-->
                                                    		<button type="button" class="btn btn-success btn-xs m-b-5"><i class="fa fa-sort-amount-desc"></i>置顶</button>
                                                    		<!--{/if}-->
						                                	<!--{if $diary['detail']['geo']}-->
                                                    		<button type="button" class="btn btn-default btn-xs m-b-5"><i class="ion-location"></i> $diary['detail']['geo']['name']</button>
                                                    		<!--{/if}-->
                                                    		<p>
	                                                    		<span class="label label-primary">评论数：$diary['detail']['commentTimes']</span>
							                                	<span class="label label-purple">查看数：$diary['detail']['viewTimes']</span>
							                                	<span class="label label-pink">喜欢数：$diary['detail']['likeTimes']</span>
                                                                <span class="label label-success"><!--{eval echo date('Y/m/d H:i:s',$diary['time'])}--></span>
                                                                <!--{if $diary['detail']['url_struct'][0]['url_type'] == 'article'}-->
                                                                <a href="admin.php?ac=article_class&op=getArticleInfo&uid={$diary[detail][url_struct][0][url_extend][uid]}&aid={$diary[detail][url_struct][0][url_type_id]}" target="_blank">
                                                                    <span class="label label-primary">点击查看文章详情</span>
                                                                </a>
                                                                <!--{/if}-->
                                                                <!--{if $diary['detail']['essence']}-->
                                                                <span class="label label-warning">热门</span>
                                                                <!--{/if}-->
	                                                    	</p>
                                                    	</blockquote>
                                                    </td>
                                                    <td class="attributes">
	                                                    <!--{if $diary['detail']['topic']}-->
                                                    		<a href="admin.php?ac=diarytopic_class&op=getDiarysByTopic&gid={$diary['detail']['topic'][0]['id']}" class="btn btn-primary btn-xs m-b-5 topsort"># $diary['detail']['topic'][0]['name']</a>
                                                    	<!--{/if}-->
                                                    </td>
				                                    <td class="actions" data-bodyid="$diary['bodyId']" data-uid="$diary['detail']['user']['uid']" data-gid="$diary['detail']['topic'][0]['id']">
						                                <div class="btn-group">
						                                    <button type="button" class="btn btn-success dropdown-toggle btn-sm" data-toggle="dropdown" aria-expanded="true">管理 <span class="caret"></span></button>
						                                    <ul class="dropdown-menu" role="menu">
						                                        <!--{if $diary['detail']['topic']}-->
                                                                <li><a target="_blank" href="/admin.php?ac=admin&do=accountOperation&uid=<!--{$diary['eUid']}-->">查看用户</a></li>
						                                        <li><a href="#" class="display">置顶到话题</a></li>
						                                        <li><a href="#" class="revert">取消置顶</a></li>
						                                        <!--{/if}-->
						                                        <li class="divider"></li>
						                                        <li><a href="admin.php?ac=diary_class&op=getDiaryDetail&bodyId=$diary['bodyId']&uid=$diary['detail']['user']['uid']">点滴详情</a></li>
																<li><a href="#" data-bodyid="$diary['bodyId']" class="remen">热门</a></li>
                                                                <!--{if !$diary['detail']['essence']}-->
																<li><a href="javascript:;" data-bodyid="$diary['bodyId']" data-topicid="$diary['detail']['topic'][0]['id']" class="addHotDiary">加入话题热门点滴</a></li>
                                                                <!--{else}-->
                                                                <li><a href="javascript:;" data-bodyid="$diary['bodyId']" data-topicid="$diary['detail']['topic'][0]['id']" class="delHotDiary">取消话题热门点滴</a></li>
                                                                <!--{/if}-->
                                                                <li><a href="javascript:;" data-bodyid="$diary['bodyId']" class="diaryinfo tuijian">推荐</a></li>
						                                    </ul>
						                                </div>
				                                        <a href="#" class="on-default remove-row delete-diary btn btn-default btn-sm"><i class="fa fa-trash-o"></i></a>
				                                    </td>
                                                </tr>
                                                <!--{/loop}-->
                                             </tbody>
                                         </table>
                                         <!--{if $pageUrl}-->
		                                 <ul class="pager">
		                                    <li> 
		                                        <a href="{$pageUrl['prev']}"> <i class="fa fa-angle-double-left"></i>上一页</a> 
		                                    </li> 
		                                    <li> 
		                                        <a href="{$pageUrl['first']}"> <i class="fa"></i>第一页</a> 
		                                    </li> 
		                                    <li> 
		                                        <a href="{$pageUrl['next']}">下一页 <i class="fa fa-angle-double-right"></i> </a> 
		                                    </li> 
		                                 </ul>
		                                 <!--{/if}--> 
                                     </div>
                                 </div>
                             </div>
                         </div>
                     </div>
                 </div>

            </div>
            <!-- Page Content Ends -->
            <!-- ================== -->
            
            <div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
      
  			</div><!-- /.modal -->
            

            <!-- Footer Start -->
            <!--{template admin_v2/footer}-->
            <!-- Footer Ends -->



        </section>
        <!-- Main Content Ends -->
        <!-- js placed at the end of the document so the pages load faster -->
        <script src="<!--{eval echo register_static('js/jquery.js');}-->"></script>
        <script src="<!--{eval echo register_static('js/bootstrap.min.js');}-->"></script>
        <script src="<!--{eval echo register_static('js/pace.min.js');}-->"></script>
        <script src="<!--{eval echo register_static('js/wow.min.js');}-->"></script>
        <script src="<!--{eval echo register_static('js/jquery.nicescroll.js');}-->" type="text/javascript"></script>

		<script src="<!--{eval echo register_static('js/jquery.app.js');}-->"></script>
		<script src="<!--{eval echo register_static('layer/layer.js');}-->"></script>
        <script src="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.js');}-->"></script>
        <script src="<!--{eval echo register_static('assets/datatables/dataTables.bootstrap.js');}-->"></script>
        <script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.js');}-->"></script>
        <script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.init.js');}-->"></script>
        
        <!-- Modal-Effect -->
        <script src="<!--{eval echo register_static('assets/modal-effect/js/classie.js');}-->"></script>
        <script src="<!--{eval echo register_static('assets/modal-effect/js/modalEffects.js');}-->"></script>
		<script type="text/javascript">
            $(document).ready(function() {
            	// 设置table配置
                $('#datatable').dataTable({
                	"iDisplayLength": 50,
                	"aLengthMenu": [10, 20, 50, 100],
                	"searching": false,
                	"bLengthChange" : false,
                	"bSort" : false,
                	"bPaginate": false
                });
				//设置推荐
				$(document).on('click','.tuijian',function(){
					var bodyId=$(this).data('bodyid');
					var sort=0;
					if(sort = window.prompt('输入排序号：')) {
						$.post('admin.php?ac=diarytopic_class&op=setDiaryRecommend&bodyId='+bodyId+'&sort='+sort, {},
								function(r){
									if(!r) {alert('操作失败');return;}; alert('操作成功')});;}else{return false;}
				})
				//设置热门
				$(document).on('click','.remen',function(){
					var bodyId=$(this).data('bodyid');
					var score=0;
					if(score = window.prompt('输入排序号：')) {
						$.get('admin.php?ac=manage&op=setHotDiaryCache&bodyId='+bodyId+'&score='+score, {},
								function(r){
									if(!r) {alert('操作失败');return;}; alert('操作成功')});;}else{return false;}
				})
                //设置话题精选点滴
                $(document).on('click','.addHotDiary',function(){
                    var bodyId=$(this).data('bodyid');
                    var topicId=$(this).data('topicid');
                    var score=0;

                    $.get(
                        'admin.php?ac=manage&op=setTopicHotDiaryCache&bodyId='+bodyId+'&topicId=' + topicId + '&score='+score,
                        {},
                        function(r){
                            if(!r) {
                                alert('操作失败');
                                return;
                            };
                            alert('操作成功');
                            location.reload();
                        }
                    );

                })
                //删除话题精选点滴
                $(document).on('click','.delHotDiary',function(){
                    var bodyId=$(this).data('bodyid');
                    var topicId=$(this).data('topicid');
                    var score=0;

                    $.get(
                        'admin.php?ac=manage&op=delTopicHotDiaryCache&bodyId='+bodyId+'&topicId=' + topicId + '&score='+score,
                        {},
                        function(r){
                            if(!r) {
                                alert('操作失败');
                                return;
                            };
                            alert('操作成功');
                            location.reload();
                        }
                    );

                })
                //获取参与数
                $(document).on('click','.getJoinNum',function () {
                    var gid = $(this).data('gid');
                    var i = layer.load();
                    $.ajax(
                            {
                                url     :   "admin.php?ac=diary_class&op=getJoinNum",
                                type    :   "POST",
                                data    :   {gid : gid},
                                success :   function(data)
                                {
                                   layer.close(i);
                                   $('.diarynum').html(parseInt(data.diarynum));
                                   $('.joinnum').html(parseInt(data.joinnum));
                                }
                            });
                });
            	//topcomment
            	$('.topsort').click(function(){
            		layer.load();
            	})
            	
             	// 置顶点滴
                $(".display").click(function() {
                	var diary = $(this).parent().parent().parent().parent().data();
                	var uid   = diary.uid;
                	var bodyId= diary.bodyid;
                	var gid= diary.gid;

                	swal(
                		{   
	                		title: "确定置顶?",
	                		type: "warning",   
	                		showCancelButton: true,   
	                		confirmButtonColor: "#DD6B55",   
	                		confirmButtonText: "Sure!",   
	                		closeOnConfirm: false 
                		}, 
                		function(){
                			$.ajax(
                		            {
                		                url     :   "admin.php?ac=diary_class&op=displayTopicDiary",
                		                type    :   "POST",
                		                data    :   {uid : uid, bodyId : bodyId, gid : gid, revert: 0},
                		                success :   function(data)
                		                            {
                		                				if (data) {
                		                					swal("置顶成功!", "已将该点滴在这个话题中取消置顶！", "success");
                		                				}else{
                		                					swal("置顶失败!", "置顶失败！", "error"); 
                		                				}
                		                				refresh();
                		                            }
                		            });
                		});
                });
             	
             	// 恢复置顶点滴
                $(".revert").click(function() {
                	var diary = $(this).parent().parent().parent().parent().data();
                	var uid   = diary.uid;
                	var bodyId= diary.bodyid;
					var gid   = diary.gid

                	swal(
                		{   
	                		title: "确定取消置顶?",
	                		type: "warning",   
	                		showCancelButton: true,   
	                		confirmButtonColor: "#DD6B55",   
	                		confirmButtonText: "Sure!",   
	                		closeOnConfirm: false 
                		}, 
                		function(){
                			$.ajax(
                		            {
                		                url     :   "admin.php?ac=diary_class&op=displayTopicDiary",
                		                type    :   "POST",
                		                data    :   {uid : uid, bodyId : bodyId, gid : gid, revert : 1},
                		                success :   function(data)
                		                            {
                		                				if (data) {
                		                					swal("取消置顶成功!", "已将该点滴取消置顶到这个话题中！", "success");
                		                				}else{
                		                					swal("取消置顶失败!", "取消置顶失败！", "error"); 
                		                				}
                		                				refresh();
                		                            }
                		            });
                		});
                });

                $(document).off('mouseenter', '.showImg').on('mouseenter', '.showImg', function () {
                    layer.tips('<img style="width: 383px;height: 858px" src="'+$(this).attr('src')+'" />', $(this), {
                        tips: [2, '#fff'],
                    });
                });

                $(document).off('mouseleave', '.showImg').on('mouseleave', '.showImg', function () {
                    layer.closeAll();
                });
             	
             	// 删除点滴
                $(".delete-diary").click(function() {
                	var diary = $(this).parent().data();
                	var uid   = diary.uid;
                	var bodyId= diary.bodyid;

                	swal(
                		{   
	                		title: "确定删除?",
	                		text: "被删除点滴不可以被恢复，请慎重操作!",
	                		type: "warning",   
	                		showCancelButton: true,   
	                		confirmButtonColor: "#DD6B55",   
	                		confirmButtonText: "Sure!",   
	                		closeOnConfirm: false 
                		}, 
                		function(){
                			$.ajax(
                		            {
                		                url     :   "admin.php?ac=diary_class&op=removeDiary",
                		                type    :   "POST",
                		                data    :   {uid : uid, bodyId : bodyId},
                		                success :   function(data)
                		                            {
                		                				if (data) {
                		                					swal("删除成功!", "该点滴已被管理员删除！", "success");
                		                				}else{
                		                					swal("删除失败!", "该点滴删除出现了问题！", "error"); 
                		                				}
                		                				refresh();
                		                            }
                		            });
                		});
                });

             	
             	// 刷新当前页面
        		function refresh(){
        		    setInterval(window.location.reload(),5000);
        		}
            } );
        </script>
    </body>
</html>
